package com.spark.demonetty.netty_demo.server;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * @author fuqiang
 * @Description netty服务端
 * @Date 2020/10/20
 */
public class NettyServer extends AbstractServer{

    @Override
    public ServerBootstrap getDefaultBootstrap() {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup,workerGroup)
                .channel(NioServerSocketChannel.class)
                .option(ChannelOption.SO_BACKLOG,1024)
                .childHandler(new ChildChannelHandler());
        return b;
    }

    public static void main(String[] args) {
        int port = 10010;
        if(args != null && args.length > 0){
            port = Integer.valueOf(args[0]);
        }
        new NettyServer().bind(port);
    }
}
